package com.silverbox.waimai.service.order;

import java.util.List;
import java.util.Map;

import com.silverbox.waimai.entity.MsgRecord;
import com.silverbox.waimai.entity.ReceiptTimeoutWaimai;
import com.silverbox.waimai.entity.Waimai;
import com.silverbox.waimai.entity.WaimaiBath;
import com.silverbox.waimai.entity.WaimaiOperateRelated;
import com.silverbox.waimai.entity.WaimaiTimeRelated;
import com.silverbox.waimai.entity.extend.WaimaiParam;
import com.silverbox.waimai.entity.extend.AlreadyGoods;
import com.silverbox.waimai.entity.extend.CopyGoods;
import com.silverbox.waimai.entity.extend.WaimaiExtend;

public interface WaimaiService {
	/**
	 * 根据订单号获取订单以及明细
	 * 
	 * @param storeId
	 * @param buyerId
	 * @return
	 */
	WaimaiExtend getWaimaiAndDetailByOrderNum(String orderNum);

	/**
	 * 根据订单号获取订单
	 * 
	 * @param orderNum
	 * @return
	 */
	Waimai getWaimaiByOrderNum(String orderNum);

	/**
	 * 保存订单
	 * 
	 * @param waimai
	 * @return
	 */
	void addWaimai(Waimai waimai);

	/**
	 * 更新订单
	 * 
	 * @param waimai
	 * @return
	 */
	int updateWaimai(Waimai waimai);

	/**
	 * 获取订单（根据桌台或者用户id）
	 * 
	 * @param waimaiParam
	 * @return
	 */
	Waimai getWaimai(WaimaiParam waimaiParam);

	/**
	 * 获取预订单
	 * 
	 * @param waimaiParam
	 * @return
	 */
	Waimai getPreparationWaimai(WaimaiParam waimaiParam);

	/**
	 * 获取订单以及明细
	 * 
	 * @param waimaiParam
	 * @return
	 */
	WaimaiExtend getWaimaiAndDetail(WaimaiParam waimaiParam);

	/**
	 * 获取历史订单以及明细
	 * 
	 * @param waimaiParam
	 * @return
	 */
	List<WaimaiExtend> getHistoryWaimaiList(WaimaiParam waimaiParam);

	/**
	 * 根据订单id更新订单项
	 * 
	 * @param id
	 */
	void updateWaimaiItem(Long id);

	/**
	 * 批量删除订单
	 * 
	 * @param ids
	 * @return
	 */
	void deleteOrderByIds(List<String> ids);

	/**
	 * 获取仿菜
	 * 
	 * @param storeId
	 * @param tableUid
	 * @param stareDate
	 * @param endDate
	 * @return
	 */
	List<CopyGoods> getCopyGoods(Integer storeId, String tableUid, String stareDate, String endDate);

	/**
	 *  根据订单号批量删除历史订单
	 * @param orderNum
	 */
	void deleteOrderByOrderNum(List<String> orderNums);
	
	/**
	 * 删除订单项里餐具费、打包费订单项
	 * @param waimaiId
	 * @param barCode
	 * @return
	 */
	int deleteBagOrBoxItemByWaimaiId(Long waimaiId);

	/**
	 * 根据条件修改订单状态
	 * @param waimai
	 * @return
	 */
	int updateWaimaiByCleanTable(WaimaiParam waimai);

	/**
	 * 获取已点过的菜
	 * @param storeId
	 * @param buyerId
	 * @param createDate
	 * @return
	 */
	List<AlreadyGoods> getAlreadyGoods(Integer storeId,Long thirdUserInfoId,String createDate);
	
	/**
	 * 获取在线订单未核销订单
	 * @param param
	 * @return
	 */
	List<WaimaiExtend> getOnlineOrderHexiao(WaimaiParam param);

	/**
	 * 获取在线订单取餐柜订单
	 * @param param
	 * @return
	 */
	List<WaimaiExtend> getOnlineMealOrder(WaimaiParam param);

	/**
	 * 更新订单信息根据订单id或订单号
	 * @param param
	 * @return
	 */
	int updateWaimaiIdOrNum(WaimaiParam param);

	/**
	 * 根据订单号修改订单信息
	 * @param param
	 * @return
	 */
	int updateWaimaiByOrderNum(Waimai param);
	
	/**
	 * 修改创建订单时间表
	 * @param timeRelated
	 */
	int updateWaimaiTimeRelated(WaimaiTimeRelated timeRelated);
	
	/**
	 * 保存创建订单时间表
	 * @param timeRelated
	 */
	int saveWaimaiTimeRelated(WaimaiTimeRelated timeRelated);
	
	/**
	 * 保存或修改订单批次号信息
	 * @param waimaiBath
	 * @return
	 */
	int saveOrUpdateWaimaiBath(WaimaiBath waimaiBath);

	/**
	 * 保存订单超时记录表
	 * @param receiptWaimai
	 * @return
	 */
	int saveReceiptTimeoutWaimai(ReceiptTimeoutWaimai receiptWaimai);

	/**
	 * 获取订单超时记录表信息
	 * @param orderNum
	 * @return
	 */
	ReceiptTimeoutWaimai getReceiptTimeoutWaimai(String orderNum);
	
	/**
	 * 保存订单操作关联表
	 * @param waimaiOperateRelated
	 * @return
	 */
	int saveWaimaiOperateRelated(WaimaiOperateRelated waimaiOperateRelated);
	
	/**
	 * 获取当天在线订单预约未核销订单
	 * @param param
	 * @return
	 */
	List<WaimaiExtend> getTodayOrderHexiaoOrDelivery(WaimaiParam param);

	List<Waimai> getMyUnPayOrder(Integer storeId, String tableName, String buyerId);

	void deleteUnpayHistoryOrderById(Long id);
	
	/**
	 * 保存下单消息
	 * @param msgRecord
	 * @return
	 */
	int saveMsgRecord(MsgRecord msgRecord);
	
	/**
	 * 根据店铺Id和机器号去查询消息记录
	 * @param storeId
	 * @param machineId
	 * @return
	 */
	List<MsgRecord> selectMsgRecord(Integer storeId, Long machineId);
	
	/**
	 * 根据消息msgCode删除消息
	 * @param msgCode
	 */
	void deleteMsgRecord(String msgCode);

    Map<String,Object> findAllOrdersByShop(Long shopId, String shopName, Integer outSupportId, Integer pageNo, Integer pageSize, List<String> buyerId);

    Map<String,Object> findAllOrders(String appId, String storeName, Integer outSupportId, Integer pageNo, Integer pageSize, List<String> buyerId);

    List<WaimaiExtend> getWaimaiByBuyerIdInUnPaidEffective(String buyerId);
}
